﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.ActiveRecord;

namespace ZDSoft.TES.Entity.FunctionEntity
{
    [ActiveRecord("Quota")]
    public class Quota : EntityBase<Quota>
    {
        /// <summary>
        /// 指标名称
        /// </summary>
        [Property]
        public string QuotaName { get; set; }

        /// <summary>
        /// 百分比(权重)
        /// </summary>
        [Property]
        public double Percentage { get; set; }

        /// <summary>
        /// 父级指标
        /// </summary>
        [BelongsTo("ParentID", Lazy = FetchWhen.OnInvoke)]
        public Quota Parent { get; set; }

        /// <summary>
        /// 子级指标
        /// </summary>
        [HasMany(typeof(Quota), ColumnKey = "ParentID", Inverse = true, Lazy = true)]
        public IList<Quota> Children { get; set; }

        [HasAndBelongsToMany(typeof(Rule), Table = "RuleQuota", ColumnKey = "QuotaID", ColumnRef = "RuleID", Inverse = true, Lazy = true)]
        public IList<Rule> Rules { get; set; }

        [BelongsTo("QuestionID", Lazy = FetchWhen.OnInvoke)]
        public Question Question { get; set; }
    }
}
